package com.redstar.interesting.common.enums;

/**
 * @author lihongxing
 */

public enum EnumServerCode {

    SUCCESS(200, "成功"),

    SERVER_UNKNOWN_ERROR(-9999, "系统繁忙，请稍后再试"),

    PARAMETER_ERROR(-100, "参数错误"),

    DATA_NOT_FOUND(-400, "数据没找到"),

    ;

    private int code;

    private String desc;

    EnumServerCode(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.desc;
    }

    public static EnumServerCode getInstance(int code) {
        for (EnumServerCode entity :EnumServerCode.values()){
            if (entity.getCode() == code) {
                return entity;
            }
        }

        return null;
    }
}
